class: middle, right, title-slide # Visualizing brain data ## - the ggseg-suite of R-packages - ### Athanasia Monika Mowinckel ### 10 - Nov - 2020 --- class: middle .pull-left[ <img src="https://www.sv.uio.no/psi/personer/vit/athanasm/athanasia.mowinckel.2.small.png" width="auto" height="600px" /> ] .pull-right[ ## Athanasia Monika Mowinckel - Staff scientist - PhD in cognitive psychology - Software Carpentry Instructor - Currently doing quite some R-package development & other in-house research software development - Find me - Twitter: [DrMowinckels](https://twitter.com/DrMowinckels) - GitHub: [Athanasiamo](https://github.com/Athanasiamo) - Website/Blog: [DrMowinckels.io](https://drmowinckels.io/) ] --- background-image: url(https://www.lifebrain.uio.no/vrtx/decorating/resources/images/logo.png), url(https://www.lifebrain.uio.no/web-banner_rev.jpg), url(https://www.lifebrain.uio.no/vrtx/decorating/resources/images/eu-flag.jpg) background-position: 50% 10%, 50% 80%, 90% 10% --- layout: true <div class="my-sidebar"></div> --- class: dark, center, middle # Neuroimaging workflows --- background-image: url(https://fsl.fmrib.ox.ac.uk/fsl/wiki_static/fsl/img/fsl-logo-x2.png), url(https://freesurfer2016.sciencesconf.org/conference/freesurfer2016/pages/FSlogo.png), url(https://nipype.readthedocs.io/en/latest/_static/nipype-banner-bg.png), url(https://www.mathworks.com/matlabcentral/mlc-downloads/downloads/98b0f6cf-f7e6-4051-b4f4-2aacf06f551b/a5cdc6ec-7ee3-4aaa-afbd-f283c68dd149/images/screenshot.png) background-size: 20%, 40%, 50%, 20% background-position: 20% 45%, 70% 45%, 85% 90%, 20% 95% ## MRI analyses are usually run in specialized software ??? - run in specialized software - but results and dissemination is usually run in stats software - switching between different software creates workflows that are hard to reproduce and keep track of --- background-image: url(https://visceralmind.files.wordpress.com/2017/04/voxel-brain.jpg?w=1024) background-size: contain ??? - the images are 3d matrices of 1mm cubic voxels, usually around 100 thousand voxels per brain - MRI analyses run large numbers of comparisons just within a single subjects' brain, and issues with multiple comparisons need to be dealt with --- background-image: url(https://www.researchgate.net/profile/Arno_Klein2/publication/233889622/figure/fig2/AS:271987822034957@1441858358467/Regions-in-the-DKT-cortical-labeling-protocol-Cortical-regions-of-interest-included-in.png) background-size: contain ??? - To reduce this problem, the brain is often reduced to a smaller set of functionally or structurally meaningful parcellations - here: the DK cortical atlas on an inflated brain (blown up like a balloon) to see also inside the grooves - measurements are extracted from these regions for metrics like coritcal thickness, surface area, gyrification index etc. and used in statistical models --- class: center, dark background-image: url(img/ggseg.png), url(img/ggseg3d.png), url(img/ggsegExtra.png) background-size: 15% background-position: 41% 43%, 59% 43%, 50% 77% # ggseg-suite .pull-left[ 2d polygons / geospatial ] -- .pull-left[ 3d mesh / tri-surface ] -- <br><br><br><br><br><br><br><br><br> <br><br><br><br><br><br><br><br><br> atlas creation / installation --- class: middle, center, dark background-image: url(img/ggseg.png) background-size: 18% background-position: 50% 10% # ## Plotting 2d representations as polygons --- class: middle .pull-left[ ```r library(ggseg, quietly = TRUE) *ggseg(atlas = dk, * mapping = aes(fill = region), colour = "black", show.legend = FALSE) + scale_fill_brain("dk") ggseg(atlas = dk, mapping = aes(fill = region), colour = "black", * position = "stacked", show.legend = FALSE) + scale_fill_brain("dk") ``` ] .pull-right[ <img src="index_files/figure-html/unnamed-chunk-2-1.png" width="100%" /><img src="index_files/figure-html/unnamed-chunk-2-2.png" width="100%" /> ] --- .pull-left[ ## Using results data ```r library(dplyr, quietly = TRUE) someData <- tibble( region = rep(c("transverse temporal", "insula", "precentral", "superior parietal"),2), p = sample(seq(0,.5,.001), 8), Group = c(rep("G1",4), rep("G2",4))) someData %>% ggseg(atlas = dk, position = "stacked", colour = "black", * mapping = aes(fill = p)) ``` ] .pull-right[ ``` ## ## Attaching package: 'dplyr' ``` ``` ## The following object is masked from 'package:kableExtra': ## ## group_rows ``` ``` ## The following objects are masked from 'package:stats': ## ## filter, lag ``` ``` ## The following objects are masked from 'package:base': ## ## intersect, setdiff, setequal, union ``` <img src="index_files/figure-html/unnamed-chunk-3-1.png" width="100%" /> ] --- .pull-left[ ## Faceting groups ```r someData %>% * group_by(Group) %>% ggseg(atlas = dk, position = "stacked", colour = "black", mapping = aes(fill = p)) + * facet_wrap(~Group, * nrow = 2) ``` ] .pull-right[ <img src="index_files/figure-html/unnamed-chunk-4-1.png" width="100%" /> ] --- class: middle .pull-left[ ## Subcortical atlases ```r *ggseg(atlas = aseg, mapping = aes(fill = region), colour = "black", show.legend = FALSE) + scale_fill_brain("aseg") ``` ] .pull-right[ <img src="index_files/figure-html/unnamed-chunk-5-1.png" width="100%" /> ] --- class: middle, center, dark background-image: url(img/ggseg3d.png) background-size: 18% background-position: 50% 10% # ## Plotting 3d triangular meshes --- class: middle .pull-left[ ## Powered by plotly ### Fully interactive ```r library(ggseg3d, quietly = TRUE) ggseg3d(atlas = dk_3d) ``` ] .pull-right[
] --- class: middle .pull-left[ ## subcortical structure ### with glass brain for reference ```r library(magrittr, quietly = TRUE) ggseg3d(atlas = aseg_3d) %>% add_glassbrain(hemisphere = "left") %>% remove_axes() ``` ] .pull-right[